package cn.edu.ncu.housinghub.mapper.chat;

import cn.edu.ncu.housinghub.entity.chatsession.ChatMessage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ChatMessageMapper {
    // 保存消息
    int saveMessage(ChatMessage message);

    // 获取会话历史消息
    List<ChatMessage> getMessagesBySessionId(@Param("sessionId") Long sessionId,
                                             @Param("pageNum") int pageNum,
                                             @Param("pageSize") int pageSize);

    // 更新消息为已读
    int updateMessageStatus(@Param("sessionId") Long sessionId, @Param("receiverId") Long receiverId);

    // 获取未读消息数量
    int getUnreadCount(@Param("sessionId") Long sessionId, @Param("receiverId") Long receiverId);
}